/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package session01;

import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.*;
import javax.swing.plaf.basic.BasicSliderUI;

/**
 *
 * @author macbookpro
 */
public class JFrameTest {
    public static void main(String[] args) {
        JFrame frm = new JFrame("The First Swing Appication");

        /* MVC */
//        frm.addWindowListener(new WindowAdapter() {
//
//            @Override
//            public void windowClosing(WindowEvent e) {
//                super.windowClosing(e);
//                System.exit(0);
//            }
//            
//        });
        
        frm.setLayout(new FlowLayout());
        
        //Tao mot Label
        JLabel lblUserName = new JLabel("User Name: ");
        
        //Lay ra Panel va them lblUserName vao:
        frm.getContentPane().add(lblUserName);
        
        //Tao mot TextField
        final JTextField txtUserName = new JTextField("User Name ....");
        
        //Lay ra Panel va them txtUserName vao:
        frm.getContentPane().add(txtUserName);
        
        //Tao mot JButton
        JButton btn = new JButton("Login");
        btn.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                txtUserName.setText("Hello World!");
            }
        });
        //Lay Pane vaf them btn vao:
        frm.getContentPane().add(btn);
        
        //Look And Feel
        try {
//            UIManager.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
//            UIManager.setLookAndFeel("com.sun.java.swing.plaf.motif.MotifLookAndFeel");
//            UIManager.setLookAndFeel("com.sun.java.swing.plaf.gtk.GTKLookAndFeel");
//            UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());

//            UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());

        } catch (ClassNotFoundException ex) {
            Logger.getLogger(LookAndFeel.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(LookAndFeel.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(LookAndFeel.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(LookAndFeel.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        frm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        
        frm.setSize(400, 300);
        frm.setVisible(true);
    }
}
